﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using MyLib;

namespace Portal
{
    public partial class SelectItemInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        void DataBind()
        {

            StringBuilder strSql = new StringBuilder();
            strSql.AppendFormat("select * from wf_item");
            DataTable dt = DataAccess.Instance("BizDB").ExecuteDataTable(strSql.ToString());
            RepeaterItemInfo.DataSource = dt;
            RepeaterItemInfo.DataBind();
        }

        //查询
        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = txtItemName.Text.ToString().Trim();//成本归属
            string no = txtNo.Text.ToString().Trim();//项目编号
            string projectname = iprojectname.Text.ToString().Trim();//项目名称
            string department = idepartment.Text.ToString().Trim();//所属片区
            if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(no) && string.IsNullOrEmpty(projectname) && string.IsNullOrEmpty(department))
            {

                Response.Write("<script type='text/javascript'>alert('请至少填写1个查询条件！');</script>");
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(@"select * from wf_item t where t.costbelong like '%{0}%' and t.itemno like '%{1}%' and t.projectname like '%{2}%' and t.department like '%{3}%'", name, no, projectname, department);

                DataTable dt = DataAccess.Instance("BizDB").ExecuteDataTable(sb.ToString());
                RepeaterItemInfo.DataSource = dt;
                RepeaterItemInfo.DataBind();
            }
        }
    }
}